package com.itheima.d2_byte_stream.practice;

import java.io.*;

/**
 * 目标：使用字节流完成对文件的复制操作。
 */
public class FileCopy {
    public static void main(String[] args) throws Exception {

        // 需求：复制照片。

        File src = new File("day09file-io-app/image01/R-C.jpg");

        File file = new File("day09file-io-app/image02/R-C.jpg");

        copyFile(src,file);
    }
    public static void copyFile(File src,File file) throws IOException {
        FileInputStream fis = new FileInputStream(src);
        FileOutputStream fos = new FileOutputStream(file);

        byte[] buf = new byte[1024];
        int len;
        while ((len= fis.read(buf))!=-1){
            fos.write(buf,0,len);
        }
        fos.close();
        fis.close();
    }
}
